import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:safetymonitor/app/components/custom_app_bar.dart';
import 'package:safetymonitor/app/core/core.dart';
import 'package:safetymonitor/app/core/ext/widget_extension.dart';
import 'package:safetymonitor/modules/home/snap_shot_danger/no_completed/view.dart';

import 'completed/view.dart';
import 'controller.dart';
import 'package:safetymonitor/app/core/utils/user_manager.dart';
/// 随手拍（隐患）重构
class SnapShotDangerPage extends StatelessWidget {
  SnapShotDangerPage({super.key});

  final controller = Get.put(SnapShotDangerController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.bg_color_grey,
      appBar: CustomAppBar(
        titleText: '隐患整改',
      ),
      body: DefaultTabController(
        length: 2,
        initialIndex: controller.initPage,
        child: Column(
          children: [
            Container(
              padding: EdgeInsets.symmetric(horizontal: 30.w),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(8),
              ),
              height: 54.w,
              child: TabBar(
                enableFeedback: false,
                tabs: const [
                  Tab(text: '待完成'),
                  Tab(text: '已完成'),
                ],
                dividerColor: Colors.transparent,
                labelPadding: EdgeInsets.only(bottom: 10.w),
                labelStyle: TextStyle(
                  fontSize: 16.sp,
                  fontWeight: FontWeight.w500,
                ),
                unselectedLabelStyle: TextStyle(
                  fontSize: 16.sp,
                  fontWeight: FontWeight.w500,
                ),
                labelColor: Colors.black,
                unselectedLabelColor: const Color(0xffA0A7B5),
                indicatorPadding: EdgeInsets.only(top: 36.w, bottom: 10.w),
                indicator: const BoxDecoration(
                  image: DecorationImage(
                    image: AssetImage(
                      'assets/images/icon_select_arc.png',
                    ),
                  ),
                ),
              ),
            ),
            Expanded(
              child: Container(
                color: const Color(0xffF5F5F6),
                child: TabBarView(
                  children: [
                    NoCompletedPage(),
                    CompletedPage(),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
      bottomSheet: UserManager.getUserCompanyId()== 100 ?
      Container(
        height: 60.w,
        alignment: Alignment.center,
        padding: EdgeInsets.symmetric(horizontal: 16.w),
        decoration: BoxDecoration(
          color: Colors.white,
          boxShadow: [
            BoxShadow(
              color: const Color(0xffBCBCC5).withOpacity(0.3), // 阴影颜色
              offset: const Offset(0, -5), // 阴影的偏移量，向上偏移，即上方阴影
              blurRadius: 10.0, // 阴影的模糊半径
              spreadRadius: 2.0, // 阴影的扩散半径
            ),
          ],
        ),
        child: Container(
            height: 40.w,
            alignment: Alignment.center,
            decoration: BoxDecoration(
                color: const Color(0xff5C6DFF),
                borderRadius: BorderRadius.all(
                  Radius.circular(20.w),
                )),
            child: Text(
              '新增隐患',
              style: TextStyle(
                fontSize: 16.sp,
                color: const Color(0xffffffff),
              ),
            )).clickOnce(controller.add),
      ):null,
    );
  }
}
